<template>
	<view class="page"> 
		<view v-if="isLogin" class="body">
			<view class="module-wrap"> 
				
				<view class="row">
					<view class="grow-3" @click="go(userAuth.qmfk_show,'/package_active/index/index','全民防控')"><image src="@/static/images/qmfk_icon.png" mode="widthFix"></image></view>
				</view>
				 				
				<view class="row ">
					<view class="item grow-1" @click="go(userAuth.ydc_show,'/package_yundiaocha/index/index','云调查')"><image src="@/static/images/ydc_icon.png" mode="widthFix"></image></view>
					<view class="item grow-2" @click="go(userAuth.yfk_show,'/package_yunfangkong/index/index','云防控')"><image src="@/static/images/yfk_icon.png" mode="widthFix"></image></view>
				</view>
				  <view class="row">
					<view class="item grow-3" @click="go(userAuth.zy_show,'/package_project/projectList/projectList','专业项目')"><image src="@/static/images/xm_icon.png" mode="widthFix"></image></view>
				</view>
				
				<view class="row r-3">
					<view class="grow-4">
						<view class="item" @click="go(userAuth.ysb_show,'/package_yunshangbao/index/index','云上报')"><image src="@/static/images/ysb_icon.png" mode="widthFix"></image></view>
						<view class="br"></view>
						<view class="item" @click="go(userAuth.ypx_show,'/package_yunpeixun/index/index','云培训')"><image src="@/static/images/ypx_icon.png" mode="widthFix"></image></view>
					</view>
					<view class="grow-5">
						<view class="item" @click="go(userAuth.yj_show,'/package_yaoji/index/index','药剂管理')"><image src="@/static/images/yj_icon.png" mode="widthFix"></image></view>
					</view>					
				</view>
				 
				
				<view class="row">
					<view class="grow-3" @click="go(userAuth.ssp_show,'/package_suishoupai/index/index','随手拍')"><image src="@/static/images/ssp_icon.png" mode="widthFix"></image></view>
				</view> 				 
			</view>
		</view>
	</view>
</template>

<script>
	import {
		getSystemInfo
	} from '@/common/promise.js'
	export default {
		data() {
			return {
				isLogin: false,
				userInfo: uni.getStorageSync('userInfo'),
				userAuth:{},
				screen_width:'',
				screen_height:'',
			}
		},
		async onLoad() {  
			 
		},
		async onShow() { 
			this.isLogin=await this.$loginState('check');
			this.userInfo=uni.getStorageSync('userInfo'); 
			this.getUserAuth();
			this.getSystemInfo();
		},
		methods: {
			
			// 获取终端系统信息
			getSystemInfo: async function() {
				let res = await getSystemInfo(); 
				this.screen_width=res.screenWidth;
				this.screen_height=res.screenHeight; 
				return res
			},
			
			// 获取用户权限信息
			getUserAuth:async function(){
				let res=await this.$api.user_api.getUserInfo({
					ret_type:1
				});    
				if(res.data.ret==0){  
					res.data.data.alltype=res.data.data.alltype.split(','); 
					this.userAuth=res.data.data;
					uni.setStorage({
						key:"userAuth",
						data:res.data.data
					})
				}				
			},
			
			go(type,router,name){ 
				// type 1 已开通功能 
				if(type==1){
					uni.navigateTo({
						url:router
					})
				}else{
					uni.showModal({
						content:"您还未开通“"+name+"”功能，可联系管理员申请开通！",
						cancelText:"暂不申请",
						confirmText:"联系申请",
						success(res) {
							if(res.confirm){
								uni.makePhoneCall({
									phoneNumber: '13560111110' 
								});
							}
						}
					})
				}
			}
			
		}
	}
</script>

<style lang="less" scoped>
	.module-wrap{
		width: 96%;
		margin: 20rpx auto;
		image{
			width: 100%;
		}
		.row{
			display: flex;
			align-items: center;
			margin-bottom: 15rpx;
		}
		.item{
			flex-shrink: 0;
		}
	}
	.row{
		justify-content: space-between;
		.grow-1{ 
			width: 57%;
		}
		.grow-2{ 
			width: 41%;
		}
		.grow-3{
			width: 100%;
		}		
	}
	.r-3{
		align-items: stretch; 
		.grow-4{
			display: flex; 
			flex-direction: column;
			flex-wrap: wrap;
			justify-content: space-between;
			width: 50%; 
			height: 100%;
			.item{
				flex-grow: 2;
			}
			.br{
				height: 24rpx;
			}
		}
		.grow-5{
			width: 48%;
		}
	}
	
	
</style>
